//
//  CameraRecoder.h
//  ChatForHot
//
//  Created by wr on 2018/10/18.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreImage/CoreImage.h>
#import "Common.h"

@class CameraRecorder;
@protocol CameraRecorderDelegate <NSObject>

@optional
- (void)HOTCHATdidStartCurrentRecording:(NSURL *)fileURL;

- (void)HOTCHATdidFinishCurrentRecording:(NSURL *)outputFileURL duration:(CGFloat)videoDuration totalDuration:(CGFloat)totalDuration error:(NSError *)error;

- (void)HOTCHATdoingCurrentRecording:(NSURL *)outputFileURL duration:(CGFloat)videoDuration recordedVideosTotalDuration:(CGFloat)totalDuration;

- (void)HOTCHATdidRemoveCurrentVideo:(NSURL *)fileURL totalDuration:(CGFloat)totalDuration error:(NSError *)error;

@required
- (void)HOTCHATdidRecordingMultiVideosSuccess:(NSArray *)outputFilesURL;
- (void)HOTCHATdidRecordingVideosSuccess:(NSURL *)outputFileURL;
- (void)HOTCHATdidRecordingVideosError:(NSError*)error;

- (void)HOTCHATdidTakePictureSuccess:(NSString *)outputFile;
- (void)HOTCHATdidTakePictureError:(NSError*)error;

@end


@interface CameraRecorder : NSObject <AVCaptureFileOutputRecordingDelegate>

@property (nonatomic, weak) id <CameraRecorderDelegate> delegate;
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;

- (CGFloat)HOTCHATgetTotalVideoDuration;
- (NSUInteger)HOTCHATgetVideoCount;

- (void)HOTCHATdeleteLastVideo;
- (void)HOTCHATdeleteAllVideo;

- (void)HOTCHATstartRecordingToOutputFileURL:(NSURL *)fileURL;
- (void)HOTCHATstopCurrentVideoRecording;
- (void)HOTCHATendVideoRecording;
- (UIImage*)HOTCHATcapturePicture;

- (BOOL)HOTCHATisTorchOn;
- (BOOL)HOTCHATisFrontCamera;

- (BOOL)HOTCHATisCameraSupported;
- (BOOL)HOTCHATisFrontCameraSupported;
- (BOOL)HOTCHATisTorchSupported;

- (void)HOTCHATswitchCamera;
- (void)HOTCHATopenTorch:(BOOL)open;

@end
